<%@ page language="java" contentType="text/html;charset=UTF-8" %>
<%@ include file="/static/include/taglib.jsp" %>
<!DOCTYPE html>
<html>
<head>
    <meta name="viewport" content="width=device-width"/>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
    <title>队伍考核-关联单位</title>
    <link href="${ctxStatic}/layui/css/layui.css" rel="stylesheet"/>
    <link href="${ctxStatic}/css/kpiui.css" rel="stylesheet"/>
    <script src="${ctxStatic}/js/jquery-1.8.3.min.js?v=2.0" type="text/javascript"></script>
    <script src="${ctxStatic}/layui/layui.all.js" type="text/javascript"></script>
</head>
<body>
<form class="layui-form" id="formedit" name="formedit" action="create_kpiscore" method="post"
      target="d41d8cd98f00b204e9800998ecf8427e">
    <iframe name="d41d8cd98f00b204e9800998ecf8427e" src="about:blank" style="display:none;"></iframe>
    <div class="indexcontent">


        <div class="selftable" id="selftable">
            <table cellspacing="0" cellpadding="0" border="0" class="layui-table" style="margin:0;">
                <thead>
                <tr>
                    <th style="width: 160px">被评单位</th>
                    <c:forEach var="itemth" items="${titleh}" varStatus="idxStatus">
                        <th style="width: 50px">${itemth.uassingredients }<br/>

                            <input id="${itemth.assindexid}" name="w_${itemth.assindexid}"
                                   value="${itemth.kpiweight}"
                                   style="  display: inline-block; width: 60px; color: rgba(255,255,255,0.80);background: #2A68A6;border: 1px solid #589DF5;">%
                        </th>
                    </c:forEach>
                    <th style="width: 50px">考评红线监测扣分</th>
                    <th style="width: 50px">总计</th>
                </tr>
                </thead>


                <tbody>
                <c:forEach var="item" items="${databody}" varStatus="idxStatus">
                    <tr>
                        <td>${item['orgname']}</td>
                        <c:forEach var="itembody" items="${titleh}" varStatus="idxStatus">
                            <%--<td>${item[itembody.assindexid]}</td>--%>
                            <td>
                                <input type="text"
                                       style="width: 69px"
                                       name="score_${item['orgid']}_${itembody.assindexid}" lay-verify="required|number"
                                       autocomplete="off" class="layui-input" value="${item[itembody.assindexidcolum]}">
                            </td>
                        </c:forEach>
                        <td><input name="red_${item.orgid}" class="red_${item.orgid}  redScore"
                                   style=" width: 50px;  color: rgba(255,255,255,0.80);background: #2A68A6;border: 1px solid #589DF5;">
                        </td>
                        <td>${item['sumscore']}</td>

                    </tr>
                </c:forEach>

                </tbody>
            </table>
        </div>
    </div>
    <div class="layui-form" style="margin:0 auto;margin-top: 10px;width:90%;color:#ffffff">
        <table style="width:100%">
            <tr>
                <td style="text-align: center" colspan="2">

                    <button class="button" id="btnsave">保存打分
                    </button>
                    <input type="button" value="关闭" class="button"
                           onclick="top.CloseOpenWindow()"/>

                </td>
                <td>
                    <input type="hidden" value="${templateid}" id="templateid" name="templateid">
                </td>
            </tr>
        </table>
    </div>
</form>

<script>
    $(function () {
        var form;
        var button;
        layui.use(['layer', 'form', 'button'], function () {
            form = layui.form; //只有执行了这一步，部分表单元素才会自动修饰成功
            button = layui.button;
            button.render();
            form.render();
        });

        getWeight();
    })


    function getWeight() {

        $.ajax({
            type: "POST",
            url: "getWeight",
            data: {
                templateid: $('#templateid').val()
            },
            beforeSend: function (XHR) {

            },
            success: function (data) {
                data = JSON.parse(data)
                if (data.length <= 0) {

                    $('.redScore').val(0);
                }
                for (var i = 0; i < data.length; i++) {

                    $('.red_' + data[i].orgid).val(data[i].redscore);
                }
            },
            complete: function (XHR) {
            },
            error: function () {
            }
        });
    }
    function CloseDialog(result, msg) {
        if (result > 0) {
            top.mylayui.msg('操作成功', {icon: 1});
        } else {
            top.mylayui.msg('操作失败', {icon: 0});
        }
        var index = parent.layer.getFrameIndex(window.name);

        parent.layer.close(index);
        return;
    }

    function changedKpi(obj) {
        var element = $(obj);
        var maxNum = element.attr('maxNum');
        var value = element.val();

        if (parseFloat(value) > parseFloat(maxNum)) {
            element.val('')
        }
    }
</script>

</body>
</html>